/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.webservicecomponent.metadata.serializer;

import com.inspur.edp.webservicecomponent.metadata.WebServiceComponent;
import com.inspur.edp.webservicecomponent.metadata.WebServiceOperation;
import com.inspur.edp.webservicecomponent.metadata.parameter.HelpFetchValueSetting;
import com.inspur.edp.webservicecomponent.metadata.parameter.ParameterFetchValueMode;
import com.inspur.edp.webservicecomponent.metadata.parameter.WebServiceParameter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Kaixuan Shi
 * @version 0.1
 */
public class ComponentInit {
    public static WebServiceComponent get() {
        WebServiceComponent component = new WebServiceComponent();
        component.setId("id");
        component.setCode("code");
        component.setName("name");
        component.setDescription("des");
        component.getOperations().add(getOperation());
        component.getOperations().add(getOperation());
        return component;
    }

    public static WebServiceOperation getOperation() {
        WebServiceOperation op = new WebServiceOperation();
        op.setId("id");
        op.setCode("code");
        op.setName("name");
        op.setDescription("des");
        op.addParameter(getParameter());
        op.addParameter(getParameter());
        Map<String, String> extend = new HashMap<>();
        extend.put("serviceId", "349239492394234");
        op.setDict(extend);
        return op;
    }

    private static WebServiceParameter getParameter() {
        WebServiceParameter param = new WebServiceParameter();
        param.setCode("code");
        param.setName("name");
        param.setDescription("des");
        param.setFetchValueMode(ParameterFetchValueMode.HELP);
        HelpFetchValueSetting setting = new HelpFetchValueSetting();
        setting.setHelpCode("code");
        setting.setHelpId("id");
        setting.setServiceUnit("su");
        setting.setHelpName("name");
        param.setFetchValueSetting(setting);
        return param;
    }
}
